<template>
	<view class="preview">
		<swiper circular>
			<swiper-item v-for="(item,index) in 5">
				<image @click="maskChange" src="../../common/images/banner2.jpg" mode="aspectFill"></image>
			</swiper-item>
		</swiper>
		<view class="mask" v-show="showState">
			<view class="goBack" @click="goBack"
			:style="{top:getStatusBarHeight()?getStatusBarHeight()+4+'px':'10px'}">
				<uni-icons type="back" color="#fff" size="28"></uni-icons>
			</view>
			<view class="count">3 / 5</view>
			<view class="time">
				<uni-dateformat :date="new Date()" format="hh:mm"></uni-dateformat>
			</view>
			<view class="date">
				<uni-dateformat :date="new Date()" format="MM月dd日"></uni-dateformat>
			</view>
			<view class="footer">
				<view class="box" @click="clickInfo">
					<uni-icons type="info" size="23"></uni-icons>
					<view class="text">信息</view>
				</view>
				<view class="box" @click="clickScore">
					<uni-icons type="info" size="23"></uni-icons>
					<view class="text">5分</view>
				</view>
				<view class="box" @click="boxClick">
					<uni-icons type="info" size="23"></uni-icons>
					<view class="text">下载</view>
				</view>
			</view>
		</view>

		<uni-popup ref="infoPopup" type="bottom" border-radius="10px 10px 0 0">
			<view class="infoPopup">
				<view class="popHeader">
					<view></view>
					<view class="title">壁纸信息</view>
					<view class="close" @click="closePopup">
						<uni-icons type="closeempty" size="18" color="#999"></uni-icons>
					</view>
				</view>
				<scroll-view scroll-y>
					<view class="content">
						<view class="row">
							<view class="label">壁纸ID:</view>
							<text selectable class="value">aaaaaaaaaaaabb</text>
						</view>
						<view class="row">
							<view class="label">壁纸ID:</view>
							<view class="value class">
								明星美女
							</view>
						</view>
						<view class="row">
							<view class="label">发布者:</view>
							<text selectable class="value">安贝兄弟</text>
						</view>
						<view class="row">
							<view class="label">评分:</view>
							<view class="value roteBox">
								<uni-rate readonly value="3" max="5" />
								<text selectable class="score">5分</text>
							</view>
						</view>
						<view class="row">
							<view class="label">摘要:</view>
							<text selectable class="value">模型美女</text>
						</view>
						<view class="row">
							<view class="label">标签:</view>
							<view class="value tabs">
								<view class="tab" v-for="(item,index) in 3">标签名</view>
							</view>
						</view>
						<view class="copyright">
							这里是版权声明
						</view>
					</view>
				</scroll-view>
			</view>
		</uni-popup>
		<uni-popup ref="scorePopup" :is-mask-click="false">
			<view class="scorePopup">
				<view class="popHeader">
					<view></view>
					<view class="title">壁纸评分</view>
					<view class="close" @click="closeScorePopup">
						<uni-icons type="closeempty" size="18" color="#999"></uni-icons>
					</view>
				</view>
				<view class="content">
					<uni-rate v-model="userScore"></uni-rate>
					<text class="text">{{userScore}}</text>
				</view>
				<view class="footer">
					<button @click="submitScore" type="default" size="mini" plain
						:disabled="userScore===0">确认评分</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {getStatusBarHeight,getTitleBarHeight,getGavBarHeight,getLeftIconLeft} from "@/utils/system.js"
	
	const showState = ref(true)
	const infoPopup = ref(null) //和vue2写法不一样
	const scorePopup = ref(null) //和vue2写法不一样
	const userScore = ref(0)
	console.log(userScore.value)
	const maskChange = () => {
		showState.value = !showState.value
	}
	const closePopup = () => {
		infoPopup.value.close()
	}
	const closeScorePopup = () => {
		scorePopup.value.close()
	}
	const boxClick = () => {
		console.log('aaa')
	}
	
	const goBack = ()=>{
		uni.navigateBack()
	}
	const clickInfo = () => {
		infoPopup.value.open('bottom')
	}
	const clickScore = () => {
		scorePopup.value.open()
	}
	const submitScore=()=>{
		
	}
	
</script>

<style lang="scss" scoped>
	.preview {
		width: 100%;
		height: 100vh; //有滚动条，如果要去，把标题导航去掉
		// height: 100%;
		position: relative;

		swiper {
			height: 100%;
			width: 100%;

			image {
				height: 100%;
				width: 100%;
			}
		}

		.mask {
			&>view {
				//选取相邻子元素
				position: absolute;
				left: 0;
				right: 0;  //居中
				margin: auto;
				color: #fff;
				width: fit-content;
			}

			.goBack {
				width: 48rpx;
				height: 48rpx;
				background: rgba(0, 0, 0, 0.5);
				left: 30rpx;
				margin-left: 0;
				border-radius: 100rpx;
				top: 0;
				backdrop-filter: blur(10rpx);
				border: 1rpx solid rgba(255,255,255,0.3);
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.count {
				top: 10vh;
				background: rgba(0, 0, 0, 0.3);
				font-size: 28rpx;
				border-radius: 40rpx;
				padding: 8rpx 28rpx;
				backdrop-filter: blur(10rpx);
			}

			.time {
				font-size: 140rpx;
				top: calc(10vh + 80rpx);
				font-weight: 100;
				line-height: 1em; //设置为当前字体大小的1倍
				text-shadow: 0 4rpx rgba(0, 0, 0, 0.3); //背景是白色看不清，所以加阴影
			}

			.date {
				font-size: 34rpx;
				top: calc(10vh + 230rpx);
				text-shadow: 0 4rpx rgba(0, 0, 0, 0.3); //背景是白色看不清，所以加阴影

			}

			.footer {
				background: rgba(255, 255, 255, 0.3);
				bottom: 10vh;
				border-radius: 1200rpx;
				height: 120rpx;
				width: 65vw;
				color: #000;
				display: flex;
				justify-content: space-around;
				align-items: center;
				box-shadow: 0 2rpx 0 rgba(0, 0, 0, 0.1);
				backdrop-filter: blur(20rpx);

				.box {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					padding: 2rpx 28rpx; //增加触碰区域

					.text {
						font-size: 26rpx;
						color: $text-font-color-2;
					}
				}
			}
		}

		.popHeader {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.title {
				color: $text-font-color-2;
				font-size: 26rpx;
			}

			.close {
				padding: 6rpx;
			}
		}

		.infoPopup {
			background: #fff;
			padding: 30rpx;
			border-radius: 30rpx 30rpx 0 0;



			scroll-view {
				max-height: 40vh;

				.content {
					.row {
						display: flex;
						justify-content: center;
						align-items: center;
						padding: 16rpx 0;
						font-size: 32rpx;
						line-height: 1.7em;

						.label {
							color: $text-font-color-3;
							width: 140rpx;
							text-align: right;
							font-size: 30rpx;
							margin-right: 10rpx;
						}

						.value {
							flex: 1;
							width: 0;
						}

						.roteBox {
							display: flex;
							align-items: center;

							.score {
								font-size: 26rpx;
								color: $text-font-color-2;
								padding-left: 10rpx;

							}
						}

						.class {
							color: $brand-theme-color;
						}

						.tabs {
							display: flex;
							flex-wrap: wrap;
							align-items: center;

							.tab {
								border: 1rpx solid $brand-theme-color;
								color: $brand-theme-color;
								font-size: 22rpx;
								padding: 10rpx 30rpx;
								border-radius: 30rpx;
								line-height: 1em;
								margin: 0 10rpx 10rpx 0;
							}
						}
					}

					.copyright {
						font-size: 28rpx;
						padding: 20rpx;
						background: #f6f6f6;
						color: #666;
						border-radius: 10rpx;
						margin: 20rpx 0;
						line-height: 1.6em;
					}
				}

			}
		}

		.scorePopup {
			background: #fff;
			padding: 30rpx;
			width: 70vw;
			border-radius: 30rpx;

			.content {
				padding: 30rpx 0;
				display: flex;
				justify-content: center;
				align-items: center;

				.text {
					color: #ffca3e;
					padding-left: 10rpx;
					width: 80rpx;
					line-height: 1em;
					text-align: right;
				}
			}

			.footer {
				padding: 10rpx 0;
				display: flex;
				justify-content: center;
				align-items: center;
			}

		}
	}
</style>